import type { DefaultOptionType } from "ant-design-vue/es/select"

export const STATE_LIST = [
  { label: '已发布', value: 1 },
  { label: '未发布', value: 0 }
]

export const STATE_OPTION = [
  { label: '发布', value: 1 },
  { label: '不发布', value: 0 }
]

export const FLAG_OPTION = [
  { label: '已作答', value: 1 },
  { label: '未作答', value: 0 }
]
export const STATUS_OPTION = [
  { label: '全部', value: '' },
  { label: '显示', value: 1 },
  { label: '不显示', value: 0 }
]
export const USERTYPE_OPTION = [
  { value: '', label: '全部用户' },
  { value: 'wechat', label: '微信公众号用户' },
  { value: 'routine', label: '微信小程序用户' },
  { value: 'h5', label: 'H5用户' }
]
export const PAY_COUNT = [
  { value: '', label: '全部' },
  { label: '1+', value: 1, },
  { label: '2+', value: 2, },
  { label: '3+', value: 3, },
  { label: '4+', value: 4, },
  { label: '5+', value: 5, },
]
export const USER_RECORD = [
  { value: '0', label: '消费记录' },
  { value: '2', label: '签到记录' },
  { value: '3', label: '持有优惠券' },
  { value: '4', label: '余额变动' },
  { value: '5', label: '好友关系' }
]
export const DISPLAY_OPTION = [
  { label: '显示', value: 1 },
  { label: '隐藏', value: 0 }
]
export const SHOW_OPTION = [{ label: '全部', value: -1 }].concat(DISPLAY_OPTION)
export const CATE_TYPE = [ // 1 产品分类，2 附件分类，3 文章分类， 4 设置分类， 5 菜单分类， 6 配置分类， 7 秒杀配置
  { name: '产品分类', value: 1, shortName: '产品' },
  { name: '附件分类', value: 2, shortName: '附件' },
  { name: '文章分类', value: 3, shortName: '文章' },
  { name: '设置分类', value: 4, shortName: '设置' },
  { name: '菜单分类', value: 5, shortName: '菜单' },
  { name: '配置分类', value: 6, shortName: '配置' },
  { name: '秒杀配置', value: 7, shortName: '秒杀' }
]
export const AUDIT_OPTION = [
  { label: '通过', value: 1 },
  { label: '未通过', value: 0 }
]

export const RESULT_TYPE = [
  { label: '统一结果', value: 0 },
  { label: '分段结果', value: 1 },
]
export const PLATFORM_TYPE = [
  { label: "通知会员", value: "1" },
  { label: "通知平台", value: "2" },
]
export const FEE_TYPE = [
  { label: '按件数', value: 1 },
  { label: '按重量', value: 2 },
  { label: '按体积', value: 3 },
]
export const DAYS_TYPE = [
  { label: '全部', value: '' },
  { label: '今天', value: 'today' },
  { label: '昨天', value: 'yesterday' },
  { label: '最近7天', value: 'lately7' },
  { label: '最近30天', value: 'lately30' },
  { label: '本月', value: 'month' },
  { label: '本年', value: 'year' }
]
export const PAY_TYPE = [
  { label: '微信公众号', value: 'public' },
  { label: '微信H5支付', value: 'weixinh5' },
  { label: '小程序', value: 'routine' },
]
export const FEE_MAP = list2map(FEE_TYPE)
export const STATE_MAP = list2map(STATE_LIST)

export const FLAG_MAP = list2map(FLAG_OPTION)

export const DISPLAY_MAP = list2map(DISPLAY_OPTION)

export const AUDIT_MAP = list2map(AUDIT_OPTION)

function list2map(list: DefaultOptionType[] = []) {
  return list.reduce((pre: Record<string, unknown>, cur: DefaultOptionType) => {
    const { label, value } = cur
    pre[value as string] = label
    return pre
  }, {} as Record<string, unknown>)
}